#include <iostream>

const int N = 1e5 + 5, M = 1e6 + 5;

int n, m;
char s[M], p[N];

int next[N];

int main()
{
    std::cin >> n >> p + 1 >> m >> s + 1;

    // next 
    for (int i = 2, j = 0; i <= n; ++i) {
        while (j && p[i] != p[j + 1]) j = next[j];
        if (p[i] == p[j + 1]) ++j;
        next[i] = j;
    }

    // kmp
    for (int i = 1, j = 0; i <= m; ++i) {
        while (j && s[i] != p[j + 1]) j = next[j];
        if (s[i] == p[j + 1]) ++j;
        if (j == n) {
            std::cout << i - n << " ";
            j = next[j];
        } 
    }
    
    return 0;
}